package com.kenliang.netty.rpc.parallel;

import com.kenliang.netty.rpc.parallel.policy.AbortPolicy;

import java.util.concurrent.*;

/**
 * @author KenLiang
 * @description:
 * @date Created in 6:33 PM 2019/3/24.
 */
public class RpcThreadPool {


    public static Executor getExecutor(int threadNum,int queueSize){
        //maxThreadSize和coreThreadSize一样，活跃
        //fixme 配置多种队列，多种拒绝策略，评估
        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(threadNum, threadNum, 0, TimeUnit.MILLISECONDS,
                new ArrayBlockingQueue<>(queueSize),
                new NamedThreadFactory("rpc-thread-pool"),
                new AbortPolicy());
        return threadPoolExecutor;
    }
}
